home *** CD-ROM | disk | FTP | other *** search
/ Night Owl 6 / Night Owl's Shareware - PDSI-006 - Night Owl Corp (1990).iso / 010a / dskctl20.zip / DSKSET.DOC < prev    next >
Text File  |  1991-09-08  |  21KB  |  409 lines

  1.                                  DISK PARAMETERS
  2.  
  3.  
  4. Are you thinking about replacing your old fixed disk with a newer, faster one?
  5. If so, you may have discovered that you also need to replace your disk control-
  6. ler.  DSKSET and DSKDRV are a pair of programs that could eliminate the need for
  7. a new disk controller.
  8.  
  9. You may need a new controller to support your new disk for any of three reasons. 
  10.  
  11. 1.  Your new disk uses Run Length Limited (RLL) encoding to increase capacity
  12. and transfer rate.
  13.  
  14. 2.  Your new disk uses a new low-level interface such as the Small Computer
  15. Systems Interface (SCSI) or Enhanced Small Disk Interface (ESDI).
  16.  
  17. 3.  Your current disk controller does not have a disk type that matches the
  18. physical characteristics of your new disk such as the number of heads and
  19. cylinders.
  20.  
  21. If you need a new controller for reasons 1 or 2, there is nothing you can do
  22. except to go ahead and make the investment.  However, very often you can get a
  23. disk that meets all of your needs without having to use a different recording
  24. mode or interface.  This is where DSKSET and DSKDRV can be useful.
  25.  
  26.  
  27. SHAREWARE
  28.  
  29. DSKSET and its related products DSKDRV, DXTSET, DXTDRV, DISK, and BOOT are 
  30. shareware.  If you decide to use them after a reasonable trial period (1 month), 
  31. you are obligated to pay for them.  The fee for continued use is $10.  For this, 
  32. you may use the products indefinitely and I will send you notice of any updates
  33. for one year.  For $25, I will send you the source code immediately and will
  34. send you any updates for one year.  These fees apply to any use of the products
  35. on a single computer including government agency and commercial use.  Volume
  36. discounts and site licenses are available to reduce the cost for large users.
  37.  
  38. Send the fees and any inquiries to:
  39.  
  40.                         Ronald Q. Smith
  41.                         11 Black Oak Road
  42.                         North Oaks, Mn. 55127-6204
  43.  
  44. You may also contact me via CompuServ mail at userid 71620,514.  I will be
  45. happy to respond to any problems and suggestions for future capabilities.
  46.  
  47. USING DSKSET
  48.  
  49. CONTROLLING THE CONTROLLER  
  50.  
  51. Your controller comes with a table of disk parameter values, indexed by the disk
  52. type that you specify through the system SETUP process on your PC/AT compatible
  53. or through jumpers on the controller for your PC/XT compatible.  Your controller
  54. may have from 4 to 255 disk types predefined.  Yet there are so many different
  55. disks on the market, there is a good chance that your new disk is not one of
  56. those supported.  DSKSET and DSKDRV allow you to install a parameter table that
  57. matches that of your new disk.
  58.  
  59. First you will want to determine whether your disk controller supports your new
  60. disk.  You may use the DISK utility with the TABLE and TAX parameters for a
  61. display of the parameter table. See the sidebar THE FORMAT OF THE DISK PARAMETER
  62. TABLE for a discussion of the table format.
  63.  
  64. If there is an entry in your disk controller's parameter table that exactly
  65. matches your new drive, you need only run SETUP again to change the disk type to
  66. select that entry.  If no entry matches exactly, run SETUP and select a type
  67. that has the correct number of heads and sectors.  Then use DSKSET and DSKDRV to
  68. get the rest of the values correct.  If you have an XT compatible, there should
  69. be four to eight jumper (strapping) pin pairs on the controller card.  Half
  70. determine the disk type for the first disk and half are for the second disk. 
  71. You will have to see your controller documentation or experiment a bit to figure
  72. out the correct settings.
  73.  
  74. PC/AT AND COMPATIBLES
  75.  
  76. CREATING YOUR OWN TABLE
  77.  
  78. DSKSET.COM allows you to create a new disk parameter table entry from the DOS
  79. command line.  DSKDRV.BIN allows you to create a new disk parameter table entry
  80. within the CONFIG.SYS file.  Usually you will use DSKSET while you are format-
  81. ting your new drive and loading the initial software on it.  You can try out the
  82. parameter table to make sure you have done it correctly.  If it doesn't seem to
  83. work, you can try a different set of values without having to reboot your
  84. system.  Once everything is working correctly, put a DEVICE=DSKDRV.BIN statement
  85. in your CONFIG.SYS file with the same parameters and you can boot from your new
  86. disk.
  87.  
  88. DSKSET and DSKDRV expect the same set of input values.
  89.  
  90. DSKSET d p1,p2,p3,...
  91. DEVICE=DSKDRV.BIN d p1,p2,p3,...
  92.  
  93. d is the disk drive number and must be 0 or 1.  Your drive will be drive 0 if it
  94. is your only disk.  It will be drive 1 if you already have a disk and are adding
  95. a second one.
  96.  
  97. p1,... specify the values for the 16-byte disk parameter table.  Each entry may
  98. be a decimal or hexadecimal byte or word.  Decimal values consist of only the
  99. digits 0-9.  Hexadecimal values contain one or more of the letters A-F, H, and X
  100. (e.g., 9D, 0x42, 98H).  Byte values are 0-255(0-0xFF).  Word values are 256-
  101. 65535 (0x100-0xFFFF) or contain the letter W (e.g., 301, 2F8, W0, WF6).  If you
  102. do not provide 16 bytes of information, trailing zero bytes will be added.
  103.  
  104. You may run DSKSET twice or include two DEVICE=DSKDRV.BIN statements in
  105. CONFIG.SYS to specify parameter values for both drives 0 and 1.
  106.  
  107. HOW IT ALL WORKS
  108.  
  109. Most of the work in DSKSET and DSKDRV is done by a common subroutine DSKPARM. 
  110. Let's look at the unique parts first.  DSKSET actually starts at the label
  111. DO_PARM.  It first displays our sign-on and copyright message and then calls
  112. DSKPARM to process the command line input parameters.
  113.  
  114. DSKPARM is called with DS:SI pointing to the start of the input (in this case,
  115. offset 81H where all command line parameters go) and ES:DI pointing to the
  116. location to store the 16-byte parameter table.  We set ES:DI to point to offset
  117. 5CH in our segment as this is the first location that we are allowed to change. 
  118. Putting it here reduces the amount of resident space we are required to tie up. 
  119.  
  120. DSKPARM returns with the value of the first parameter, the drive number, in AX
  121. and the zero flag (ZF) set if everything was OK.  We will display an error
  122. message if DSKPARM finds an error or if the drive number is greater than 1.
  123.  
  124. If everything was OK, we use the DOS set-interrupt-vector function call to point
  125. the BIOS to our new parameter table.  We set interrupt number 41H if it is drive
  126. 0 and interrupt number 46H if it is drive 1.
  127.  
  128. Just pointing the BIOS to our new parameter table is not enough.  The BIOS
  129. doesn't look at all of the parameter values on every disk I/O operation and we
  130. must be sure that they all take effect.  So we now tell the BIOS disk handler to
  131. reinitialize everything again.  We start off with a slight overkill by telling
  132. the BIOS to reset the disk drive just in case it is in any funny state.  Then we
  133. tell it to take the new parameters and reinitialize the controller.  Then we do
  134. a reset again to be sure that everything starts from ground zero.
  135.  
  136. Now all we have to do is display our completion message and exit with the DOS
  137. terminate-and-stay-resident function call.  We calculate the length of the
  138. resident part by taking the offset of the parameter table that we created,
  139. adding its length (16 bytes), and rounding up to the next paragraph boundary.
  140.  
  141. DSKDRV is DSKSET written as a DOS device driver.  At the start of every DOS
  142. device driver there is a header block.  The first entry in the header is a
  143. double word which DOS will use to link the device drivers together.  We ini-
  144. tialize it to -1 per the rules for loading device drivers.
  145.  
  146. Next there is a word that contains flag bits indicating the type of driver. 
  147. Even though we are doing things related to disks which are block devices, we are
  148. not actually a block device driver.  In fact, we are not any kind of device
  149. driver.  We simply chose this mechanism to get our parameter table loaded very
  150. early in the system initialization process.  So we will tell DOS that we are a
  151. character device driver for the NUL device.  This is a trick specifically
  152. included in DOS to handle not-a-real-device drivers.  DOS will never try to call
  153. our driver except to call with the initialization function when we are loaded.
  154.  
  155. The next two entries are word offsets that point to the strategy and interrupt
  156. routines for our device driver.  The strategy routine is called first with each
  157. device request with all of the request parameters and is just supposed to save
  158. them.  DOS then immediately calls the interrupt routine with no parameters
  159. expecting it to process the request just given to the strategy routine.
  160.  
  161. (DOS obviously does not make any use of the existence of the two entry points.
  162. Equally obviously, DOS was designed with the intent of someday becoming a true
  163. multi-tasking operating system with asynchronous I/O.  Then the strategy routine
  164. would set up queues of operations to be performed and actually initiate them
  165. immediately or when appropriate hardware interrupts occurred.  DOS would call
  166. the "interrupt" routine when it needed to get the completion status of the
  167. requested operation.)
  168.  
  169. The last entry in the header for a character device is an 8-byte ASCII name of
  170. the device, in our case 'NUL     '.
  171.  
  172. Our strategy routine is only supposed to be called once at initialization.  It
  173. saves the pointers to the request parameters and returns.  
  174.  
  175. The interrupt routine is also only supposed to be called once at initialization. 
  176. Carefully following the rules that it must save all of the registers that it
  177. uses and that the stack provided by DOS is only big enough to hold the regis-
  178. ters, it saves the registers and then switches to its own stack.
  179.  
  180. Next the interrupt routine modifies the header and code so that we will truly
  181. act like a NUL device driver in case we ever get called again.  We set both the
  182. interrupt routine pointer in the header to point to the same location as the
  183. strategy routine and modify that code to simply return a normal completion
  184. status on any call.
  185.  
  186. The next part of our code looks very much like DSKSET except that we must abide
  187. by the device driver rules that we can only use DOS functions 01H-0CH and 30H. 
  188. We print the sign-on line, parse the parameters on the statement, and set the
  189. interrupt vector pointer.  We get the location of the DEVICE=DSKDRV.BIN parame-
  190. ters from the packet passed to us by DOS.  We have to change the interrupt
  191. vector by hand since we are not supposed to use the DOS function that does that. 
  192. (It is easy to see why we cannot use the DOS file and directory functions while
  193. we are still loading device drivers.  I suspect that some of the other functions
  194. like set interrupt vector would actually work just fine, but we will play
  195. strictly by the rules for safety's sake.)
  196.  
  197. We then tell the disk controller to use the new parameter table in exactly the
  198. same way as we did in DSKSET.  Since this is the BIOS we are talking to rather
  199. than DOS, we can use all of the disk functions.
  200.  
  201. Then we set the ending address of the driver to the last location that we need
  202. to keep, print the completion message, and return to DOS.
  203.  
  204. DSKPARM is a common subroutine used by both DSKSET and DSKDRV that parses the
  205. input parameters and builds the table.  DSKPARM consists of a main loop that
  206. scans the input parameters until 16 bytes are found or the end of the list is
  207. reached.  It calls the procedure GET_NUM to obtain each input value.
  208.  
  209. GET_NUM converts the next number from the input parameters.  It first skips any
  210. leading blanks and then processes all characters until a comma or blank is
  211. encountered.
  212.  
  213. GET_NUM uses an internal open procedure CNV_NUM to actually convert the charac-
  214. ters to a number.  CNV_NUM is called once to do the conversion and then fallen
  215. into to redo the conversion and exit.  This approach simplifies handling of hex
  216. numbers.  The first time we assume that we will be converting a decimal number. 
  217. If any hex digits, X, or H are encountered, the base is changed so that the
  218. second pass converts the numbers appropriately.
  219.  
  220. An error is detected if any characters other than 0-9, A-F, H, X, W, space, or
  221. comma are encountered or if the value is greater than 65535.
  222.  
  223. PC/XT AND COMPATIBLES
  224.  
  225. CREATING YOUR OWN TABLE
  226.  
  227. DXTSET.COM and DXTDRV.BIN are the PC/XT analogues to DSKSET.COM and DSKDRV.BIN
  228. respectively.  The PC/XT handles the tables so differently that it makes sense
  229. to have separate programs for the PC/XT.     The usage is very similar to the
  230. PC/AT versions except that the drive number is replaced by a type number.
  231.  
  232. DXTSET t p1,p2,p3,...
  233. DEVICE=DXTDRV.BIN t p1,p2,p3,... 
  234.  
  235. t is the number of the disk type being modified.  t will be a value in the range
  236. 0 to 15.  The PC/XT uses the same parameter table for both disk drives, so you
  237. change the entry associated with the type you have set in the jumpers on the
  238. controller.
  239.  
  240. All other parameters are the same as for the PC/AT version.  You may run DXTSET
  241. or DXTDRV multiple times to change as many type entries as you wish.
  242.  
  243. HOW IT ALL WORKS
  244.  
  245. DXTSET and DXTDRV are very similar to their PC/AT counterparts and share the
  246. common subroutine DSKPARM with them.
  247.  
  248. The PC/XT controller uses a single parameter table pointer stored at interrupt
  249. location 41H for both disk drives.  This pointer gives the location of the base
  250. (type 0) entry of the table and the controller indexes into the table using the
  251. disk type that it reads from its jumpers.  A maximum of 16 entries may appear in
  252. the table.
  253.  
  254. Since we have to have a table of 16 16-byte entries (256 bytes), we do not want
  255. to make extra copies unnecessarily.  We find the current pointer to the table
  256. using interrupt location 41H.  If it points to a location in the BIOS (segment
  257. of 0C000H or greater), we copy the entire table to our memory area.  Otherwise,
  258. we will modify the table in place.  This ensures that running DXTSET and DXTDRV
  259. multiple times does not require any additional memory.
  260.  
  261. DSKPARM is called to convert the parameters.  The first field is treated as a
  262. type number rather than a drive number, but everything else is the same.  The
  263. table entry associated with the returned type number is changed.
  264.  
  265. If we had to create a copy of the table, we reserve the proper amount of memory. 
  266. Otherwise we simply exit to DOS.
  267.  
  268. SUMMARY
  269.  
  270. DSKSET and DSKDRV can save you $100 or more for the cost of a new disk con-
  271. troller.  Any electrically compatible disk drive can be used with your con-
  272. troller as long as your controller has a definition with the same number of
  273. heads and sectors as your new disk.
  274.  
  275.                      THE FORMAT OF THE DISK PARAMETER TABLE
  276.  
  277. There are two disk parameter table formats, one for the PC/XT and one for the
  278. PC/AT.  Both require essentially the same information.  In order to construct
  279. your own parameter table you must have access to the technical specifications
  280. about your disk drive.  Most dealers supply this with the drive.  You should be
  281. sure that your dealer supplies it.  If you don't get it from your dealer, the
  282. disk manufacturer can supply it to you.
  283.  
  284.  
  285. PC/AT
  286.  
  287. The PC/AT disk controller BIOS and parameter tables are located in the system
  288. BIOS.  The format of the PC/AT parameter table is:
  289.  
  290. BYTE         SIZE   DESCRIPTION
  291.  0           Word   Total number of cylinders
  292.  2           Byte   Number of read/write heads(surfaces)
  293.  3           Word   Unused
  294.  5           Word   Starting write precompensation cylinder
  295.  7           Byte   Unused
  296.  8           Byte   Control byte
  297.                     Bit 7     No retry on disk errors
  298.                     Bit 6     No retry on ECC errors
  299.                     Bit 3     More than 8 heads
  300.  9           Byte   Not used
  301. 10           Byte   Not used
  302. 11           Byte   Not used
  303. 12           Word   Landing zone cylinder
  304. 14           Byte   Sectors/track
  305. 15           Byte   Reserved  
  306.  
  307. Offset 0(word) - Contains the total number of cylinders.  The drive specifica-
  308. tions will supply this number.  This number is 2 larger than the number that
  309. will be returned to you when you make a request to retrieve drive parameters. 
  310. The innermost cylinder is reserved as a test and landing zone cylinder and the
  311. returned drive parameters give you the largest cylinder number (starting at 0)
  312. rather than the number of cylinders.
  313.  
  314. Offset 2(byte) - Contains the total number of read/write heads.  This is also
  315. the number of read/write surfaces.  Read the specifications carefully.  Some
  316. disks have a clocking head/surface that is not used for data.  Be sure not to
  317. include the clocking head in this count.  The number in this field is 1 greater
  318. than the number returned by a request to retrieve drive parameters.  Again, the
  319. returned drive parameters give the highest head number (starting at 0) rather
  320. than the number of heads.
  321.  
  322. Offset 3(word) - Unused on a PC/AT.  Set to 0.
  323.  
  324. Offset 5(word) - Your drive specifications should identify the starting write
  325. precompensation cylinder.  They may say that write precompensation is used for
  326. the entire disk.  In that case put a 0 in this field.  They may say that write
  327. precompensation is not used in which case you should put 0xFFFF in this field.
  328.  
  329. Offset 7(byte) - Unused on a PC/AT.  Set to 0.
  330.  
  331. Offset 8(byte) - Control byte.  Set bit 3 to a 1 if your disk has more than 8
  332. read/write heads.  Bits 6 or 7 may be set if you do not want the controller to
  333. do retries.  These bits are invariably 0.
  334.  
  335. Offset 9(byte) - Unused on a PC/AT.  Set to 0.
  336.  
  337. Offset 10(byte) - Unused on a PC/AT.  Set to 0.
  338.  
  339. Offset 11(byte) - Unused on a PC/AT.  Set to 0.
  340.  
  341. Offset 12(word) - Landing zone.  Value to be used by park programs to move heads
  342. to.  Often equal to the total number of cylinders value at offset 0, but your
  343. drive specifications may define a special value to be placed here.
  344.  
  345. Offset 14(byte) - Sectors per track.  Usually 17.  If your drive specifications
  346. do not indicate what value to use, try 17.  Otherwise you may compute it from
  347. other information given in the drive specifications.  Drive specifications
  348. usually give the total number of bits per track, the size of the sector(record)
  349. headers, and the size of any required gaps.  Sometimes gaps are specified in
  350. minimum and maximum time intervals and you will have to convert that to bits
  351. using the rotational rate (often 3600 RPM) and the total number of bits per
  352. track.  Sector sizes are always 512 bytes unless you have a specially modified
  353. version of DOS.  
  354.  
  355. Offset 15(byte) - Reserved.  Set to 0.
  356.  
  357.  
  358. PC/XT
  359.  
  360. The PC/XT parameter table is located on the BIOS chip on the disk controller
  361. card.  This allowed the addition of optional controllers to a PC that was not
  362. originally designed to accommodate them.  Several of the fields are the same as
  363. in the PC/AT parameter table.  Those fields will be identified but not explained
  364. again.
  365.  
  366. BYTE         SIZE   DESCRIPTION
  367.  0           Word   Total number of cylinders
  368.  2           Byte   Number of read/write heads(surfaces)
  369.  3           Word   Reduced write current cylinder
  370.  5           Word   Starting write precompensation cylinder
  371.  7           Byte   Maximum ECC data burst length
  372.  8           Byte   Control byte
  373.                     Bit 7     No retry on disk errors
  374.                     Bit 6     No retry on ECC errors
  375.                     Bit 3     More than 8 heads
  376.                     Bits 0-2     Step rate
  377.  9           Byte   Timeout value for normal read/write operations
  378. 10           Byte   Timeout value for format operations
  379. 11           Byte   Timeout value for disk check operations
  380. 12           Word   Unused
  381. 14           Byte   Unused
  382. 15           Byte   Reserved  
  383.  
  384. Offset 3(word) - Reduced write current cylinder.  Your drive specifications
  385. should give this value.  It is often equal to the starting write precompensation
  386. cylinder.  In fact, the PC/AT controller assumes they are equivalent and only
  387. uses a single value.
  388.  
  389. Offset 7(byte) - Maximum ECC data burst length.  The maximum number of bits that
  390. the ECC can correct.  The first and last bits in error in any sector must be
  391. within this length (inclusive) of each other or the ECC cannot correct the
  392. error.  Some controllers do not use this value.  If all the values in your
  393. controller's table are 0 or the same, just use that value.
  394.  
  395. Offset 8(byte) - Control byte.  Bits 0-2 specify the head stepping rate on
  396. cylinder-to-cylinder motion.
  397.  
  398. Offsets 9-11(byte) - Timeout values.  These values are used by the BIOS software
  399. to timeout disk operations.  Normally all entries in the BIOS table contain the
  400. same values and you should just use those.  However, if your disk is very slow
  401. in transfer rate or access time, you may need to use increased values.
  402.  
  403. Offset 12(word)   - Unused on a PC/XT.  This is the landing zone field and you
  404. may want to put your drive's landing zone in it.  The BIOS does not use it, but
  405. some PARK programs do.
  406.  
  407. Offset 14(byte)   - Unused on a PC/XT.  This is the sectors per track field on a
  408. PC/AT and should be 0 or 17.
  409.